# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=weechat-matrix
pkgver=0.3.0_git20230723
pkgrel=6
_commit="feae9fda26ea9de98da9cd6733980a203115537e"
pkgdesc="WeeChat Matrix protocol script"
url="https://github.com/poljar/weechat-matrix"
arch="noarch"
license="MIT"
depends="
	py3-aiohttp
	py3-atomicwrites
	py3-attrs
	py3-cachetools
	py3-magic
	py3-matrix-nio
	py3-olm
	py3-openssl
	py3-peewee
	py3-pygments
	py3-requests
	py3-webcolors
	python3
	weechat
	weechat-python
	xdg-utils
	"
makedepends="
	py3-gpep517
	py3-importlib-metadata
	py3-installer
	py3-poetry-core
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-pytest
	"
install="$pkgname.post-install"
subpackages="$pkgname-pyc"
source="$pkgname-$_commit.tar.gz::https://github.com/poljar/weechat-matrix/archive/$_commit.tar.gz
	heisenbridge_shortname.patch
	poetry-core.patch
	"
builddir="$srcdir/$pkgname-$_commit"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m pytest
}

package() {
	python3 -m installer --destdir="$pkgdir" .dist/*.whl
	install -Dm755 main.py "$pkgdir/usr/share/weechat/python/weechat-matrix.py"

	for _script in matrix_decrypt matrix_sso_helper matrix_upload; do
		install -Dm755 "contrib/$_script.py" "$pkgdir/usr/bin/$_script"
	done
}

sha512sums="
85b2d6a9a5d393d265cf7d92bb48cf846a68319372e81121d1cedb74a184320df5cee4b0a66a5f88168e297b212f781634f65a4f4a5092ab3e64972428a76ea0  weechat-matrix-feae9fda26ea9de98da9cd6733980a203115537e.tar.gz
ebe210f88708e91a293a5c00f324263b32c418f9033c58c7afa8c8cf03d805eb3ac54f902a4f655d2d26ace8267d02063cc86d4d75f320f63a14c3964cbe2fea  heisenbridge_shortname.patch
d28d2a55daddae3319fcc4ceccf2b06826dc9af0b4ec76aa3f843008954b5c9a2e24aa7aecc8d480753a1355c5dbd104ceefc0a9a87c9e9e5f4dddca52fec9f7  poetry-core.patch
"
